//
//  TeachingViewController.m
//  Learn
//
//  Created by 迟建国 on 2024/4/4.
//  Copyright © 2024 迟建国. All rights reserved.
//

#import "TeachingViewController.h"
#import "ComputerExamCollectionViewCell.h"

@interface TeachingViewController ()<UICollectionViewDelegate, UICollectionViewDataSource>
@property (nonatomic, strong) UICollectionView *collectionView;

@end

@implementation TeachingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUI];
    // Do any additional setup after loading the view.
}
- (void)setUI {
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    layout.sectionInset = UIEdgeInsetsMake(10, 0, 10, 0);
    layout.minimumLineSpacing = 10;
    UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - NavigationBarHeight - SafeAreaBottomHeight - 49) collectionViewLayout:layout];
    collectionView.backgroundColor = UIColor.clearColor;
    collectionView.delegate = self;
    collectionView.dataSource = self;
    collectionView.showsVerticalScrollIndicator = NO;
    collectionView.showsHorizontalScrollIndicator = NO;
    collectionView.noCurrentDataImage = NO;
//    collectionView.alwaysBounceVertical = NO;
//    self.extendedLayoutIncludesOpaqueBars = YES;
    if (@available(iOS 11.0, *)) {
        collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    [collectionView registerNib:[UINib nibWithNibName:@"ComputerExamCollectionViewCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"ComputerExamCollectionViewCell"];

    [self.view addSubview:collectionView];
    self.collectionView = collectionView;
}

#pragma collectionView

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 0;
}

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    ComputerExamCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ComputerExamCollectionViewCell" forIndexPath:indexPath];
    if (!cell) {
        cell = [[[NSBundle mainBundle]loadNibNamed:@"ComputerExamCollectionViewCell" owner:self options:nil] lastObject];
    }
//    cell.model = self.model;
    return cell;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    return CGSizeMake(SCREEN_W - 20, 112);
}
@end
